package stream;

import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.*;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * 按照字符流 读文件Demo
 */
public class Demo3 {

    public static void main(String[] args) {
        try(Reader reader = new FileReader("./text1.txt")) {
            // 按照字符来读
            while (true) {
                char[] buffer = new char[1024];
                int len = reader.read(buffer);
                if (len == -1){
                    break;
                }
                for (int i = 0; i < len; i++) {
                    System.out.println(buffer[i]);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
